<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>模块管理</title>
	<link href="../../css/component.css" rel="stylesheet" type="text/css" />
</h:head>

<ui:param name="bean" value="#{modelManagerAction}" />

<h:body>
	<p:outputLabel value="模块管理:"/>
	<h:form id="fadd">
		<p:dataTable var="model" value="#{bean.model}">
			<p:column headerText="选择父模块" style="text-align:center" >
				<p:selectOneMenu value="#{model.fatherId}" label="选择父模块" >
					<f:selectItem itemLabel="选择" itemValue="0" />
					<f:selectItems value="#{bean.modelMap.entrySet()}" var="entry" itemLabel="#{entry.value.description}" itemValue="#{entry.key}" />
				</p:selectOneMenu>
			</p:column>
			<p:column headerText="模块标识" style="text-align:center" >
				<p:inputText size="16" maxlength="16"   value="#{model.id}" />
			</p:column>
			<p:column headerText="模块名称" style="text-align:center" >
				<p:inputText size="16" maxlength="64"   value="#{model.name}"/>
			</p:column>	
			<p:column headerText="模块排序" style="text-align:center" >
				<p:inputText size="16" maxlength="16"   value="#{model.sort}" />
			</p:column>				
			<p:column headerText="模块描述" style="text-align:center" >
				<p:inputText size="16" maxlength="64"  value="#{model.description}"/>
			</p:column>
			<p:column headerText="操作" style="text-align:center" width="12%">
				<p:commandButton value="查询" action="#{bean.search}" update=":flist" ajax="true"/>
			</p:column>
		</p:dataTable>
	</h:form>
	<br />

	<!-- 展示查询结果数据 -->
	<p:outputLabel value="查询结果："></p:outputLabel>
	<br />
	<h:form id="flist">
		<p:messages id="messages" showDetail="true" life="3000"/>	
		<p:dataTable id="dlist" var="model" value="#{bean.modelList}"	resizableColumns="true" paginator="true" rows="10">
			<p:column headerText="父模块" style="text-align:center" width="10%">
				<h:outputText value="#{bean.getFatherName(model.fatherId)}"/>
			</p:column>	
			<p:column headerText="模块标识" style="text-align:center" width="10%">
				<h:outputText value="#{model.id}" readonly="true"/>
			</p:column>			
			<p:column headerText="模块名称" style="text-align:center" width="18%">
				<p:inputText value="#{model.name}" size="10" maxlength="64"/>
			</p:column>
			<p:column headerText="模块排序" style="text-align:center" width="12%">
				<p:inputText value="#{model.sort}" size="4" maxlength="10"/>
			</p:column>
			<p:column headerText="模块描述" style="text-align:center" width="30%">
				<p:inputText size="16" maxlength="64"  value="#{model.description}"/>
			</p:column>		
			<p:column headerText="操作" style="text-align:center" width="20%">
				<p:commandButton value="修改" action="#{bean.modify(model)}"		update="dlist" ajax="true"/>
				<p:commandButton value="删除" action="#{bean.delete(model.id)}"	update="dlist" ajax="true">
					<p:confirm header="确认框" message="确定删除模块?" icon="ui-icon-alert" />
				</p:commandButton>
				<center>
					<p:confirmDialog global="true" showEffect="fade"
						hideEffect="explode" style="text-align:center">
						<p:commandButton value="确定" type="button"
							styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
						<p:commandButton value="取消" type="button"
							styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
					</p:confirmDialog>
				</center>
			</p:column>			
		</p:dataTable>
	</h:form>
</h:body>
</html>
